import { useEffect } from "react"
import { Outlet,useLocation,useNavigate } from 'react-router-dom'
import { message } from "antd";
export default function IndexPage(){
    const nav = useNavigate();
    const location = useLocation(); 

    useEffect(()=>{
        console.log(location)
        if(!localStorage.getItem('token')){
            if(!['/login','/register'].includes(location.pathname)){
                nav('/login')
            }
        }else{
            if(['/','/login','/register'].includes(location.pathname)){
                nav('/course')
            }
        }

    },[location.pathname])
    return <Outlet/>
}